package com.association.controller;


import com.alibaba.excel.EasyExcel;
import com.association.constant.CodeEnum;
import com.association.model.ResultResp;
import com.association.model.entity.UserAwait;
import com.association.model.vo.UserAwaitVo;
import com.association.service.UserAwaitService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.SneakyThrows;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.lang.reflect.Member;
import java.util.List;


/**
 * @author admin
 */
@Api(description = "用户",value="用户" )
@RestController
@RequestMapping("/userAwait")
public class UserAwaitController {
    @Autowired
    UserAwaitService userAwaitService;

    @ApiOperation("查询")
    @RequestMapping(value = "/getUserAwait", method = RequestMethod.GET)
    public ResultResp select(@RequestParam(required = false) Integer page,
                             @RequestParam(required = false) Integer limit,
                             @RequestParam(required = false) String nickName,
                             @RequestParam(required = false) String phone,
                             @RequestParam(required = false) String deptId,
                             @RequestParam(required = false) String sex,
                             @RequestParam(required = false) String email) {

        return userAwaitService.select(page,limit,nickName,phone,deptId,sex,email);
    }

    @ApiOperation("删除")
    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    public ResultResp delete(@RequestBody UserAwaitVo userAwaitVo) {
        return userAwaitService.delete(userAwaitVo);
    }

    @ApiOperation("批量删除")
    @RequestMapping(value = "/deleteIds", method = RequestMethod.POST)
    public ResultResp deleteIds(@RequestBody UserAwaitVo userAwaitVo) {
        return userAwaitService.deleteIds(userAwaitVo.getIds());
    }

    @ApiOperation("修改")
    @RequestMapping(value = "/edit", method = RequestMethod.POST)
    public ResultResp edit(@RequestBody UserAwaitVo userAwaitVo) {
        return userAwaitService.edit(userAwaitVo);
    }

    @ApiOperation("添加")
    @RequestMapping(value = "/save", method = RequestMethod.POST)
    public ResultResp add(@RequestBody UserAwaitVo userAwaitVo) {
        return userAwaitService.add(userAwaitVo);
    }



    @SneakyThrows
    @ApiOperation("从Excel导入面试列表")
    @RequestMapping(value = "/importMemberList", method = RequestMethod.POST)
    @ResponseBody
    public ResultResp importMemberList(@RequestPart("file") MultipartFile file) {
        return userAwaitService.addList(file);
    }

}
